import datetime

class TransDateTime:
    @staticmethod
    def trans_to_datetime(value):
        # 将一个时间字符串转化为时间对象
        if isinstance(value,str):
            if ':' in value and len(value) > 16:
                value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M:%S')
            elif ':' in value and len(value) == 16:
                value = datetime.datetime.strptime(value, '%Y-%m-%d %H:%M')
            else:
                value = datetime.datetime.strptime(value, '%Y-%m-%d')
        return value

print(type(TransDateTime.trans_to_datetime("2020-01-01 22:22:00")))
